<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_SetErrno manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> SetErrno</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="SetErrno.htm#M2" NAME="L702">NAME</A>
<DL><DD>Tcl_SetErrno, Tcl_GetErrno, Tcl_ErrnoId, Tcl_ErrnoMsg &mdash; manipulate errno to store and retrieve error codes</DD></DL>
<DD><A HREF="SetErrno.htm#M3" NAME="L703">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tcl.h&gt;</B>
<DD>void
<DD><B>Tcl_SetErrno</B>(<I>errorCode</I>)
<DD>int
<DD><B>Tcl_GetErrno</B>()
<DD>const char *
<DD><B>Tcl_ErrnoId</B>()
<DD>const char *
<DD><B>Tcl_ErrnoMsg</B>(<I>errorCode</I>)
</DL>
<DD><A HREF="SetErrno.htm#M4" NAME="L704">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="SetErrno.htm#M5" NAME="L705">DESCRIPTION</A>
<DD><A HREF="SetErrno.htm#M6" NAME="L706">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tcl_SetErrno, Tcl_GetErrno, Tcl_ErrnoId, Tcl_ErrnoMsg &mdash; manipulate errno to store and retrieve error codes
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
void<BR>
<B>Tcl_SetErrno</B>(<I>errorCode</I>)<BR>
int<BR>
<B>Tcl_GetErrno</B>()<BR>
const char *<BR>
<B>Tcl_ErrnoId</B>()<BR>
const char *<BR>
<B>Tcl_ErrnoMsg</B>(<I>errorCode</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT>int <B><A HREF="../TclCmd/tclvars.htm">errorCode</A></B> (in)<DD>
A POSIX error code such as <B>ENOENT</B>.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_SetErrno</B> and <B>Tcl_GetErrno</B> provide portable access
to the <B>errno</B> variable, which is used to record a POSIX error
code after system calls and other operations such as <B><A HREF="../TclLib/OpenFileChnl.htm">Tcl_Gets</A></B>.
These procedures are necessary because global variable accesses cannot
be made across module boundaries on some platforms.
<P>
<B>Tcl_SetErrno</B> sets the <B>errno</B> variable to the value of the
<I>errorCode</I> argument
C procedures that wish to return error information to their callers
via <B>errno</B> should call <B>Tcl_SetErrno</B> rather than setting
<B>errno</B> directly.
<P>
<B>Tcl_GetErrno</B> returns the current value of <B>errno</B>.
Procedures wishing to access <B>errno</B> should call this procedure
instead of accessing <B>errno</B> directly.
<P>
<B>Tcl_ErrnoId</B> and <B>Tcl_ErrnoMsg</B> return string
representations of <B>errno</B> values.  <B>Tcl_ErrnoId</B>
returns a machine-readable textual identifier such as
&ldquo;EACCES&rdquo;
that corresponds to the current value of <B>errno</B>.
<B>Tcl_ErrnoMsg</B> returns a human-readable string such as
&ldquo;permission denied&rdquo;
that corresponds to the value of its
<I>errorCode</I> argument.  The <I>errorCode</I> argument is
typically the value returned by <B>Tcl_GetErrno</B>.
The strings returned by these functions are
statically allocated and the caller must not free or modify them.

<H3><A NAME="M6">KEYWORDS</A></H3>
<A href="../Keywords/E.htm#errno">errno</A>, <A href="../Keywords/E.htm#error code">error code</A>, <A href="../Keywords/G.htm#global variables">global variables</A>
<div class="copy">Copyright &copy; 1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
